package cn.liyao.web.holder;

import java.util.concurrent.atomic.AtomicReference;

public class CurrentUserIdHolder {

    private static final ThreadLocal<AtomicReference<String>> currentUser = new ThreadLocal<>();

    public static void setCurrentUser(String userId) {
        currentUser.set(new AtomicReference<>(userId));
    }

    public static String getCurrentUser() {
        AtomicReference<String> userRef = currentUser.get();
        return userRef != null ? userRef.get() : null;
    }


}
